#ifndef _ACCELEROMETER_H
#define _ACCELEROMETER_H

#include <QAccelerometerFilter>
#include <math.h>

#define GRAVITY 9.81

QTM_USE_NAMESPACE

enum SOUNDS {
	NONE,
	SWING3
};

class Accelerometer : public QObject, public QAccelerometerFilter
{
	Q_OBJECT
private:
	QAccelerometer *m_sensor;
	double m_x, m_y, m_z;
	double m_amplitude;

public:
	Accelerometer(QObject *parent = NULL);
	~Accelerometer();

	/**
	 * NOT USED, use signals/slots instead.
	 * Read acceleration values from the device.
	 */
	void read(double *x, double *y, double *z);

	/** Determines the sound file played. */
	SOUNDS currentSound();
	double getAmplitude();

private slots:

	/** Overrides default QAccelerometerFilter::filter(...) */
	bool filter(QAccelerometerReading* reading);

signals:
	/** sends signal with new values */
	void readingsChanged(double x, double y, double z, double amp);
};

#endif
